package chpt08;

import java.io.File;
public class FileAttribute {
	public static void main(String[] args){
		File file = new File("C:/JavaPrj/javademo/test.txt");		
		System.out.println("file exists: " + file.exists());
		if(file.isFile()) {
			System.out.println("file is a file.");
		} else if(file.isDirectory()) {
			System.out.println("file is a directory");
		}	
		java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println(
		    "Absolute path: " + file.getAbsolutePath() +
		    "\n Can read: " + file.canRead() +
		    "\n Can write: " + file.canWrite() +
			"\n getName: " + file.getName() +
		    "\n getParent: " + file.getParent() +
		    "\n getPath: " + file.getPath() +
		    "\n length: " + file.length() +
		    "\n lastModified: " + df.format(file.lastModified()) 
		);			
	}
}
